//
//  Receiver.swift
//  命令设计模式
//
//  Created by slience on 2019/11/13.
//  Copyright © 2019 shehuiren. All rights reserved.
//

import UIKit

class Receiver: NSObject {
     
    var hud:CGFloat = 0.0
       var staturation:CGFloat = 0.0  // 饱和度
       var brightness:CGFloat = 0.0
       var alpha:CGFloat = 0.0
    
    var receiverView : UIView?{
        
        didSet{
            
            let color = receiverView!.backgroundColor!
            color.getHue(&hud, saturation: &staturation, brightness: &brightness, alpha: &alpha)
            
        }
    }
    func makeDark(paramter : CGFloat){
        
        brightness-=paramter
        brightness = max(brightness, 0)
        receiverView?.backgroundColor = UIColor(hue: hud, saturation: staturation, brightness: brightness, alpha: alpha)
    }
    
    func makeLighter(paramter : CGFloat){
        
        brightness += paramter
        brightness = min(1, brightness)
        receiverView?.backgroundColor =  UIColor(hue: hud, saturation: staturation, brightness: brightness, alpha: alpha)
    }
}
